cmake_minimum_required(VERSION 3.8)
project(slam_test)

# 设置C++标准
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 编译警告选项
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic -Wno-unused-parameter)
endif()

# 查找依赖
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(serial_driver REQUIRED)
find_package(std_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(tf2 REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(tf2_geometry_msgs REQUIRED)  # 添加这个新依赖

# 查找Eigen3库
find_package(Eigen3 REQUIRED)

# 添加可执行文件
add_executable(slam_test_node src/slam_test_node.cpp)
target_include_directories(slam_test_node PRIVATE ${EIGEN3_INCLUDE_DIRS})
ament_target_dependencies(slam_test_node
  rclcpp
  serial_driver
  std_msgs
  geometry_msgs
  tf2_ros
  tf2
  nav_msgs
  sensor_msgs
  tf2_geometry_msgs  # 添加这个新依赖
)

# 安装规则
install(TARGETS slam_test_node
  DESTINATION lib/${PROJECT_NAME}
)

# 测试配置
if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  set(ament_cmake_copyright_FOUND TRUE)
  set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

# 导出包
ament_package()